﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EasyTest {

    /// <summary>
    /// Object to compare elements and text.
    /// </summary>
    public class Verify {

        /// <summary>
        /// Compare two elements' .Text to see if they are equal.
        /// </summary>
        /// <param name="element">First Element to compare.</param>
        /// <param name="element2">Second Element to compare.</param>
        public static void AreExactlyEqual(IElement element, IElement element2) {
            AreExactlyEqual(element.GetText(), element2.GetText());
        }

        /// <summary>
        /// Compare two text strings to see if they are equal.
        /// </summary>
        /// <param name="one">First string to compare.</param>
        /// <param name="two">Second string to compare.</param>
        public static void AreExactlyEqual(string one, string two) {
            TextCompare(one, two, false, false);
        }

        /// <summary>
        /// Compare two text strings.
        /// </summary>
        /// <param name="one">First string to compare.</param>
        /// <param name="two">Second string to compare.</param>
        /// <param name="like">Check to see if the first string contains the second string.</param>
        /// <param name="ignoreCase">Compare the strings regardless of case.</param>
        private static void TextCompare(string one, string two, bool like, bool ignoreCase) {
            if (ignoreCase) {
                one = one.ToLower();
                two = two.ToLower();
            }
            if (like) {
                Assert.IsTrue(one.Contains(two));
            } else {
                Assert.AreEqual(one, two);
            }

        }
    }
}
